import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

import javax.swing.JOptionPane;

public class MastermindGUI extends JFrame {

	JTabbedPane tabbedPane;
	JPanel gamePage, helpPage;
	JLabel helpLabel, spacer;
	ImageIcon helpImage;
	Sound helpSound;
	JButton moreHelp;
	ButtonHandler buttonHandler;
	static boolean cheat;

	static GamePanel gamePanel;
	ControlPanel controlPanel;
	static StatusPanel statusPanel;

	public MastermindGUI(boolean cheat) {

		// the guess panel holds the empty slots for each turn
		gamePanel = new GamePanel();

		// pass a copy of guessPanel to the controlPanel
		// contains buttons
		controlPanel = new ControlPanel(gamePanel);

		statusPanel = new StatusPanel();

		gamePage = new JPanel();
		helpPage = new JPanel();

		// DECLARE THE TABBED PANEL
		tabbedPane = new JTabbedPane();

		// Set up the gamePage object
		gamePage.setLayout(new BorderLayout());
		gamePage.add(controlPanel, BorderLayout.NORTH);
		gamePage.add(gamePanel, BorderLayout.CENTER);
		gamePage.add(statusPanel, BorderLayout.SOUTH);

		// Set up the helpPage object
		helpImage = new ImageIcon("src/images/helpImage.gif");
		helpLabel = new JLabel(helpImage);

		spacer = new JLabel("             ");
		moreHelp = new JButton("MORE HELP");
		buttonHandler = new ButtonHandler();
		moreHelp.addActionListener(buttonHandler);
		helpPage.add(helpLabel);
		helpPage.add(spacer);
		helpPage.add(moreHelp);

		// SET UP THE TABBED PANE
		tabbedPane.addTab("GAME", gamePage);
		tabbedPane.addTab("HELP", helpPage);

		add(tabbedPane);

		this.cheat = cheat;
	}

	public static GamePanel getGamePanel() {
		return gamePanel;
	}

	public static StatusPanel getStatusPanel() {
		return statusPanel;
	}

	public static boolean getCheat() {
		return cheat;
	}

	class ButtonHandler implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			if (e.getActionCommand().equals("MORE HELP")) {
				helpSound = new Sound("src/sounds/helpSound.wav");
				helpSound.run();
			}
		}
	}
}
